const bcrypt = require('bcryptjs');

async function testPassword() {
    const password = 'newhand';
    const hash = '$2b$10$ZU0kKYdBcjRaUTZxpTYOQuK5aXKK3eohDMBxKzNVJVdQ8XsOjQg6e';
    
    console.log('测试密码:', password);
    console.log('数据库哈希:', hash);
    
    try {
        const isValid = await bcrypt.compare(password, hash);
        console.log('密码验证结果:', isValid);
        
        // 生成新的哈希进行对比
        const newHash = await bcrypt.hash(password, 10);
        console.log('新生成的哈希:', newHash);
        
        const isNewValid = await bcrypt.compare(password, newHash);
        console.log('新哈希验证结果:', isNewValid);
        
    } catch (error) {
        console.error('测试失败:', error);
    }
}

testPassword(); 